<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Golang printing</title>
		<link type="text/css" rel="stylesheet" href="static/css/P.css">
		<link type="text/css" rel="stylesheet" href="static/css/coding.css">
		<script src="static/js/Blue.js"></script>
		<script>
			var now = new Date();
			setInterval("now = setColor(now);",1000);
		</script>
	</head>
	<body>
		<header class="header">
		    <h1><small>1048576的代码课堂</small></h1>
		    &emsp;&emsp;&emsp;&emsp;&emsp;
		    <a class="smallbtn" href="index.html/#go">0基础开始的Golang教程</a>
		    &emsp;&emsp;&emsp;&emsp;&emsp;
		    <a class="smallbtn" href="javascript:alert('未做完')">Golang测验</a>
		</header>
		<div class="full" id="color">
			<div class="headerspace"></div>
			<p>
				<h3>今天，我们要用golang写一个输出“HelloWorld”的程序</h3>
					<code class="code">
						<span class="kw">package</span> main
						<br>
						<span class="kw">import</span> <span class="const">"fmt"</span>
						<br>
						<span class="spkw">func</span> main{
						<br>
						&emsp;&emsp;fmt.<span class="func">Println</span>(<span class="const">"Hello World"</span>)
                        }
					</code>
				<div class="headerspace"></div>
                把它保存到一个文件夹内（我的是D:\GolangCode\HelloWorld.go\）<br>
                打开cmd：<br>
                <code class="code">
                    >>><span class="kw">go run</span> D:\GolangCode\HelloWorld.go
                </code>
				<div class="headerspace"></div>
                就会发现真的输出了Hello World。<br>
                现在来解析这段代码：<br>
                <code class="inline"><span class="kw">package</span> main</code> ：每个文件必须包含main包。<br><br>
                <code class="inline"><span class="kw">import</span> <span class="const">"fmt"</span></code>：fmt包含基本的输入输出操作。<br><br>
                <code class="inline"><span class="spkw">func</span> main{</code>：主函数：程序的入口。<br><br>
                <code class="inline">fmt.<span class="func">Println</span>(<span class="const">"Hello World"</span>)</code>：fmt.Println() ：fmt包的Println操作输出一个值并输出回车<br><br>
                里面的Hello World必须用引号包裹，因为是一个字符串。<br>
				<span class="tips">字符串：表示文本的数据类型</span><br>
				因为字符串不单指Hello World，所以可以加任何数据如<br><br>
				<code class="inline">fmt.<span class="func">Println</span>(<span class="const">"This is a String."</span>)</code>
				
				
			</p>
			
		</div>
		
	</body>
</html>
